*cd "C:\Research\Emiss_Trade_price_controls\data\"
cd "/Users/cason/Dropbox/Research/Emiss_Trade_price_controls/data/"

use Subjects_11sessions.dta

** Drop practice period **
drop if Period<1

** Mean investment rate is multiplied by 8 firms for time series in Figure 2 **
by pri_control, sort : tabstat Invest, statistics( mean ) by(Period)

collapse (mean) meanInvest=Invest (sum) totalInvest=Invest (mean) emissShock=S, by(pri_control sess_num Period)

sort sess_num Period
preserve

** Test for treatment differences for all periods **

collapse (mean) totalInvest, by(pri_control sess_num)

ranksum totalInvest, by(pri_control)

** Now test check for differences after the 5 initial adjustment periods **
restore

drop if Period<6

collapse (mean) totalInvest, by(pri_control sess_num)

** Mean investment rate is multiplied by 8 firms for total investors in Figure 3 **
gen num_investors = 8 * totalInvest
list

ranksum totalInvest, by(pri_control)

** Now go back to check for differences by firm type **
clear
use Subjects_11sessions.dta

** Drop practice period **
drop if Period<1

preserve

collapse (mean) meanInvest=Invest, by(pri_control sess_num Subject)

by Subject, sort : ranksum meanInvest, by(pri_control)

** Check for case when dropping periods 1-5 **
restore

** Drop early periods **
drop if Period<6
** Investment rates for Figure 4 **
by pri_control, sort : tabstat Invest, statistics( mean ) by(Subject)

collapse (mean) meanInvest=Invest, by(pri_control sess_num Subject)

** p-values displayed in Figure 4 **
by Subject, sort : ranksum meanInvest, by(pri_control)

